package com.th.controller;

import com.th.common.domain.UsInternalMessage;
import com.th.common.response.CommonResponse;
import com.th.common.response.PageResult;
import com.th.service.UsInternalMessageService;
import com.th.service.UsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ErrorRua
 * @date 2023/07/05
 * @description:
 */
@RestController
@RequestMapping("/api/internal/message")
public class UsInternalMessageController {
    @Autowired
    private UsInternalMessageService usInternalMessageService;

    @GetMapping
    public CommonResponse<PageResult<UsInternalMessage>> list
            (@RequestParam(value = "page", defaultValue = "1") Integer currentPage,
             @RequestParam(value = "size", defaultValue = "10") Integer size) {
        return CommonResponse.success(usInternalMessageService.page(currentPage, size));
    }

    @GetMapping("/{id}")
    public CommonResponse<UsInternalMessage> messageDetail(@PathVariable("id") Long id) {
        return CommonResponse.success(usInternalMessageService.getMessageDetail(id));
    }

        @PutMapping("/read")
    public CommonResponse<String> read(@RequestBody List<Long> ids) {
        usInternalMessageService.read(ids);
        return CommonResponse.success("标为已读成功");
    }
}
